/**
 * 触发 window.resize
 */
export function triggerWindowResizeEvent () {
    if (typeof window === 'undefined') return
    const event = new Event('resize')
    window.dispatchEvent(event)
  }
  
  export function handleScrollHeader (callback: (arg0: string) => void) {
    let timer = 0
  
    let beforeScrollTop = window.pageYOffset
    callback = callback || function () {}
    window.addEventListener(
      'scroll',
      event => {
        clearTimeout(timer)
        timer = setTimeout(() => {
          let direction = 'up'
          const afterScrollTop = window.pageYOffset
          const delta = afterScrollTop - beforeScrollTop
          if (delta === 0) {
            return false
          }
          direction = delta > 0 ? 'down' : 'up'
          callback(direction)
          beforeScrollTop = afterScrollTop
        }, 50)
      },
      false
    )
  }